package 练习题;

import java.util.Scanner;
import java.util.Stack;

/**
 * @author Liangyaoyun
 */
public class MyStack {
    public static void main(String[] args) {
        Stack<Integer>stack=new Stack<>();
        Scanner scanner=new Scanner(System.in);
        int i;

        System.out.print("请输入您要入栈的元素:");
        i=scanner.nextInt();
        stack.add(i);
        i=scanner.nextInt();
        stack.add(i);
        i=scanner.nextInt();
        stack.add(i);
        i=scanner.nextInt();
        stack.add(i);
        i=scanner.nextInt();
        stack.add(i);
        System.out.println("栈的长度:"+stack.size());
        System.out.println("弹出栈顶元素:"+stack.pop());
        System.out.println("显示栈顶元素:"+stack.peek());

    }
}
